package Method;

import Book.BookList;

import java.util.Scanner;

//归还图书
public class ReturnOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("请输入你要归还的图书：");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();
        for (int i = 0; i < bookList.getBooksNum(); i++) {
            if (bookList.getBook(i).getName().equals(name) && (bookList.getBook(i).isBorrowed())) {
                bookList.getBook(i).setBorrowed(false);
                System.out.println("归还成功！");
                return;
            }
        }
        System.out.println("归还失败！");
    }
}
